---
title: "Connect a new Chain"
description: "Union documentation"
template: doc
---

import { Tabs, TabItem, FileTree, Steps } from '@astrojs/starlight/components'

If your chain is not yet [connected to Union](/protocol/chains/overview/), then you can permissionlessly add support. Union supports L1s, L2s, L3s, and Rollups. The steps to connect are simple:

<Steps>
1. Upload Union contracts
2. Configure a relayer
3. Open the connection
4. Send assets and data
</Steps>

## Upload Union contracts

You'll need to upload two contracts:

- [union-ibc](https://github.com/unionlabs/union/tree/main/cosmwasm/union-ibc/core): Union's modular IBC stack.
- [cometbls-light-client](https://github.com/unionlabs/union/tree/main/cosmwasm/ibc-union/lightclient/cometbls): Light-client tracking [CometBLS](/architecture/cometbls) consensus.


### Cosmos

To upload [CosmWasm](https://cosmwasm.com/) contracts to your Cosmos chain, you need your chain's binary. We'll use `starsd` in this example. 

```bash
nix build github:unionlabs/union#union-ibc -L
```

```bash
mkdir ./starsd-home
./starsd init --chain-id elgafar-1 --home ./starsd-home cor-systems
./starsd keys add cor-systems --home ./starsd-home
# this will give you your address: stars1qcvavxpxw3t8d9j7mwaeq9wgytkf5vwputv5x4
```


<Steps>
1. Upload your contract:

   ```bash
   ./starsd tx wasm store ./contracts/union_ibc.wasm --from cor-systems --home ./starsd-home --gas auto --gas-adjustment 1.4 --gas-prices 1ustars --node https://rpc.elgafar-1.stargaze.chain.kitchen --chain-id elgafar-1 -y
   # => tx_hash: C6D45BE9A40F92D82E94C0B4D2AFA48812A9FE28E5761700E496ED29F8D53977
   ```
2. Query your contract's code_id:
   ```bash
   ./starsd query tx C6D45BE9A40F92D82E94C0B4D2AFA48812A9FE28E5761700E496ED29F8D53977 --node https://rpc.elgafar-1.stargaze.chain.kitchen
   # => code_id: 5011
   ```
3. Instantiate union-ibc
   ```bash
   ./starsd tx wasm instantiate 5011 '{}' --node https://rpc.elgafar-1.stargaze.chain.kitchen --home ./starsd-home --from cor-systems --gas auto --gas-adjustment 1.4 --gas-prices 1ustars --label union-ibc-1 --admin stars1qcvavxpxw3t8d9j7mwaeq9wgytkf5vwputv5x4 --chain-id elgafar-1 -y
   # => txhash: D3E0D991E3874C83B43E0828C693F8E0A1E2A8C8CB518DFFF2F5F87FB6E1A7BC
   ```
4. Query the union-ibc contract address:

   ```bash
   ./starsd query tx D3E0D991E3874C83B43E0828C693F8E0A1E2A8C8CB518DFFF2F5F87FB6E1A7BC --node https://rpc.elgafar-1.stargaze.chain.kitchen
   # => contract_address: stars1s0x3yq0pmltxq56f4yppgmd02ret3uj5k9ftj6ug9c7lc379sw7qv396zm
   ```
5. Upload `cometbls-light-client` contract:
   ```bash
   ./starsd tx wasm store ./contracts/cometbls_light_client.wasm --from cor-systems --home ./starsd-home --gas auto --gas-adjustment 1.4 --gas-prices 1ustars --node https://rpc.elgafar-1.stargaze.chain.kitchen --chain-id elgafar-1 -y
   # => tx_hash: 187227FF10BA93B75063C9E72FBB188FA6403F43CFA80346DFC1B2F268C7C022
   ```
6. Query `cometbls-light-client` code_id:
   ```bash
   ./starsd query tx 187227FF10BA93B75063C9E72FBB188FA6403F43CFA80346DFC1B2F268C7C022 --node https://rpc.elgafar-1.stargaze.chain.kitchen
   # => code_id: 5012
   ```
7. Instantiate `cometbls-light-client`, specifying the union-ibc address acquired in step 4
   ```bash
   ./starsd tx wasm instantiate 5012 '{"ibc_host": "stars1s0x3yq0pmltxq56f4yppgmd02ret3uj5k9ftj6ug9c7lc379sw7qv396zm"}' --node https://rpc.elgafar-1.stargaze.chain.kitchen --home ./starsd-home --from cor-systems --gas auto --gas-adjustment 1.4 --gas-prices 1ustars --label union-ibc-1 --admin stars1qcvavxpxw3t8d9j7mwaeq9wgytkf5vwputv5x4 --chain-id elgafar-1 -y
   # => tx_hash: 7B6874CD6D68B735230E4F4F5C80BC92CF1AF690605C799569C01CCB7C403019
   ```
8. Query the `cometbls-light-client` contract address:
   ```bash
   ./starsd query tx 7B6874CD6D68B735230E4F4F5C80BC92CF1AF690605C799569C01CCB7C403019 --node https://rpc.elgafar-1.stargaze.chain.kitchen
   # => contract_address: stars16khctrjjnm5nn5503hhqlcu7h4pngzpzc5g3d4ej25pz47eqsnjqdctmt7
9. Register the `cometbls-light-client` to `union-ibc`:
   ```bash
   ./starsd tx wasm execute stars1s0x3yq0pmltxq56f4yppgmd02ret3uj5k9ftj6ug9c7lc379sw7qv396zm '{"register_client":{"client_type":"cometbls","client_address":"stars16khctrjjnm5nn5503hhqlcu7h4pngzpzc5g3d4ej25pz47eqsnjqdctmt7"}}' --home ./starsd-home --node https://rpc.elgafar-1.stargaze.chain.kitchen --chain-id elgafar-1 --from cor-systems --gas auto  --gas-adjustment 1.4 --gas-prices 1ustars -y
   ```
</Steps>


